package com.study.demo.mybatisplus.vo;

/**
 * @author: elvin
 * @time: 2019-05-27 13:27
 * @desc:
 **/
public enum SexEnum {

    Male("Male", "男"),

    Female("Female", "女");

    private String code;

    private String desc;

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    SexEnum(String code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public static SexEnum getByCode(String code){
        if(code == null){
            return null;
        }
        SexEnum[] values = SexEnum.values();
        for (SexEnum value : values) {
            if (value.getCode().equalsIgnoreCase(code)) {
                return value;
            }
        }
        return null;
    }

    public static SexEnum getByIndex(int index){
        switch (index){
            case 0:
                return Male;
            case 1:
                return Female;
        }
        return null;
    }
}
